Skip to content

Fix created/updated dates and address in RDAP whois nets - #960

Open
Allen Joseph G (unknownhackerworld) wants to merge 1 commit into
microsoft:mainfrom
unknownhackerworld:fix/rdap-net-created-updated
Open

Allen Joseph G (unknownhackerworld) wants to merge 1 commit into
microsoft:mainfrom
unknownhackerworld:fix/rdap-net-created-updated

Conversation

@unknownhackerworld

Copy link
Copy Markdown

_create_net in msticpy/context/ip_utils.py builds the nets entries that ip_whois returns from RDAP data. Two loops in it lose data.

Event dates. Each RDAP event reset both created and updated, and the mapping was reversed ("last changed" went to created, "registration" to updated):

for item in data["events"]:
    created = item["eventDate"] if item["eventAction"] == "last changed" else None
    updated = item["eventDate"] if item["eventAction"] == "registration" else None

Only the last event survives. ARIN lists "last changed" before "registration", so for the existing RDAP_RESPONSE fixture (13.64.0.0, MSFT) the result is created=None and updated="2015-03-26T13:58:18-04:00", which is the registration date. Expected is created="2015-03-26T13:58:18-04:00" and updated="2021-12-14T20:28:53-05:00", matching what the created / updated fields meant in the old ipwhois nets output.

Address. The entities loop assigned address = _find_address(entity) for every entity, so any later entity without an address set it back to None. With the same fixture the registrant's "One Microsoft Way..." address is dropped and address comes back None.

Fix

  • Map "registration" to created and "last changed" to updated, and only assign on a matching event, so the order of events does not matter.
  • Keep the first address found instead of the last value.
  • Use data.get("events", []) / data.get("entities", []). Both are optional members in RDAP (RFC 9083), and a response without them raised KeyError.

Testing

  • Added test_create_net_event_dates_and_address in tests/context/test_ip_utils.py. It checks the fixture's created, updated and address, the same with the events reversed, an extra trailing entity without an address, and a response with no events or entities. It fails on main (created is None, updated is the registration date, address is None) and passes with this change.
  • python -m pytest tests/context/test_ip_utils.py: 6 passed.
  • ruff check passes on both changed files.

AI disclosure: this change was prepared with the help of an AI assistant (finding the bug, writing the patch, test and this description).

_create_net reset both created and updated on every RDAP event, and
mapped "last changed" to created and "registration" to updated. With
ARIN's usual event order (last changed, then registration) the net
ended up with created=None and updated set to the registration date.
Map "registration" to created and "last changed" to updated, matching
the ipwhois field meaning, and stop resetting the value on other events.

The address was also overwritten by every entity, so a trailing
entity without an address cleared the registrant's address. Keep the
first address found. Treat events and entities as optional, since
RDAP does not require them.

Signed-off-by: Allen Joseph G <63872540+unknownhackerworld@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants